<template>
  <view :style="'max-height:'+window_height">

    <u-list
        @scrolltolower="scrollToLower"
    >
      <u-list-item
          v-for="(item, index) in form_list"
          :key="index"
      >
        <uni-card>
          <view>
            申请店铺：{{ item.shop_info.nickname }}
          </view>
          <view>
            申请时间：{{ item.created_at }}
          </view>
          <view>
            审核状态：
            <text v-if="item.status===0" class="u-warning">{{ item.status_desc }}</text>
            <text v-if="item.status===200" class="u-success">{{ item.status_desc }}</text>
            <text v-if="item.status===255" class="u-error">{{ item.status_desc }}</text>
          </view>
          <template v-if="item.status===200">
            <text class="dw-list-sub-title">尽快扫码绑定，成为分享员，15天内有效</text>
            <image :src="item.bind_qrcode" mode="heightFix"></image>
          </template>
          <template v-if="item.status===255">
            <view>
              审核备注：
              <text class="u-error">{{ item.reason }}</text>
            </view>
            <navigator
                :url="'/pages/sharer/form?shop_id='+item.shop_info.shop_id+'&shop_name='+item.shop_info.nickname+'&wechat_account='+item.wechat_account+'&mobile_number='+item.mobile_number+'&nickname='+item.nickname+'&avatar='+item.avatar">
              <text class="u-primary">重新申请</text>
            </navigator>
          </template>
        </uni-card>
      </u-list-item>
    </u-list>

  </view>
</template>

<script>

import {getSharerFormList} from "@/api/sharer";

export default {
  data() {
    return {
      form_list: [],
      next_key: '',
      has_more: true,
      window_height: 0,
    }
  },
  onLoad() {
    // 获取屏幕高度
    this.window_height = getApp().globalData.window_height

    this.getFormList()
  },
  methods: {
    // 获取店铺列表
    getFormList() {
      getSharerFormList({
        next_key: this.next_key,
        page_size: 20,
      }).then(res => {
        console.log("分享员申请列表：", res)
        this.form_list = this.form_list.concat(res.list)
        this.next_key = res.next_key
        this.has_more = Boolean(res.has_more)
      })
    },
    scrollToLower() {
      if (!this.has_more) {
        return
      }
      this.getFormList()
    },
    getTextClass(item) {
      if (item.status === 255) {
        return 'u-error'
      }
      if (item.status === 0) {
        return 'u-warning'
      }
      return 'u-success'
    }
  }
}
</script>

<style lang="scss" scoped>

</style>
